package com.jumi.microservice.schedule;

import com.jumi.microservice.constant.GoodsStatus;
import com.jumi.microservice.domain.GoodsDO;
import com.jumi.microservice.domain.GoodsScheduleDO;
import com.jumi.microservice.domain.GoodsScheduleDTO;
import com.jumi.microservice.mapper.GoodsMapper;
import com.jumi.microservice.mapper.GoodsScheduleMapper;

import java.time.LocalDateTime;


/**
 * @author Administrator
 */
public class GoodsFixPuttedOnShelvesJob {
/*    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        GoodsScheduleDTO goodsScheduleDTO =
                (GoodsScheduleDTO) jobExecutionContext.getJobDetail().getJobDataMap().get("goodsSchedule");
        GoodsScheduleMapper goodsScheduleMapper =
                (GoodsScheduleMapper) jobExecutionContext.getJobDetail().getJobDataMap().get("goodsScheduleMapper");

        GoodsMapper goodsMapper =
                (GoodsMapper) jobExecutionContext.getJobDetail().getJobDataMap().get("goodsMapper");

        GoodsDO goods = goodsMapper.selectById(goodsScheduleDTO.getGoodsId());
        if (GoodsStatus.FIX_PUTTED_ON_SHELVES.getCode().equals(goods.getGoodsState())) {
            goods.setGoodsState(GoodsStatus.PUTTED_ON_SHELVES.getCode());
            int update = goodsMapper.updateById(goods);
            if (update > 0) {
                GoodsScheduleDO goodsSchedule = new GoodsScheduleDO();
                goodsSchedule.setId(goodsScheduleDTO.getId());
                goodsSchedule.setGoodsId(goodsScheduleDTO.getGoodsId());
                goodsSchedule.setUpdateTime(LocalDateTime.now());
                goodsSchedule.setIsSuccess(1);
                goodsScheduleMapper.updateById(goodsSchedule);
            }

        }
    }*/
}
